package OoDay03;

import java.util.concurrent.Callable;

public class RefArrayDemo {
    public static void main(String[] args) {
       /* //声明Dog型数组dogs，包含三个元素，每个元素都是Dog型，默认值null
        Dog[] dogs=new Dog[3];
        //声明Chick型数组chicks，包含三个元素，每个元素都是Chick型，默认值null
        Chick[] chicks=new Chick[3];
        //声明Fish型数组fish，包含两个元素，每个元素都是Fish型，默认值null
        Fish[] fish=new Fish[2];*/

        //Dog[] dogs=new Dog[3];
        //dogs[0]=new Dog("小黑",2,"黑");

        Dog[]dogs=new Dog[3];
        dogs[0]=new Dog("小黑",2,"黑");
        dogs[1]=new Dog("小白",1,"白");
        dogs[2]=new Dog("小黄",3,"黄");
        System.out.println(dogs[0].name);
        dogs[0].age=4;
        dogs[1].swim();
        for (int i=0;i<dogs.length;i++){
            System.out.println(dogs[i]);
            dogs[i].eat();
        }

        Chick[]chicks=new Chick[2];
        chicks[0]=new Chick("小花",1,"花");
        chicks[1]=new Chick("大花",2,"花");
        for (int i=0;i<chicks.length;i++){
            System.out.println(chicks[i].color);
            chicks[i].layEggs();
        }

        Fish[]fish=new Fish[2];
        fish[0]=new Fish("小银", 3,"银");
        fish[1]=new Fish("小红", 1,"红");
        for (int i=0;i<fish.length;i++){
            System.out.println(fish[i].color);
            fish[i].eat();
        }

    }
}
